package cn.yunhe.controller;

import cn.yunhe.entity.Member;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.Date;


@Controller
public class MemberController {

    //http://localhost:8080/toLogin.dojava
    //http://localhost:8080/FreeMarker/login.ftl
    //@RequestMapping(value = "/toLogin")
    public ModelAndView toLogin1(){
        Member member=new Member();
        member.setMid(1);
        //member.setMname("王大");
        member.setMpwd("111");
        member.setAge(25);
        member.setStartTime(new Date());

        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("member111",member);
        modelAndView.setViewName("memberInfo");
        return modelAndView;
    }


    //http://localhost:8080/toLogin.dojava
    //http://localhost:8080/FreeMarker/login.ftl
    @RequestMapping(value = "/toLogin")
    public ModelAndView toLogin(HttpSession httpSession){
        Member member=new Member();
        member.setMid(2);
        member.setMname("李二");
        member.setMpwd("222");
        member.setAge(200);
        member.setStartTime(new Date());

        ModelAndView modelAndView=new ModelAndView();
        //modelAndView.addObject("member111",member);
        httpSession.setAttribute("member222",member);
        modelAndView.setViewName("memberInfo");
        return modelAndView;
    }
}
